package com.clkj.cldisabledmanclient.adapter.rv;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.clkj.cldisabledmanclient.R;
import com.clkj.cldisabledmanclient.bean.custombean.IndexHelpInfoBean;
import com.clkj.cldisabledmanclient.mvp.recoverorg.ActivityRecoverOrg;

import java.util.List;

/**
 * Created by clboys on 2019/5/19.
 */

public class RvAdapterForHelpInfo extends RecyclerView.Adapter<RecyclerView.ViewHolder> {


    List<IndexHelpInfoBean> mDataList;
    Context mContext;


    public RvAdapterForHelpInfo(List<IndexHelpInfoBean> dataList, Context context) {
        mDataList = dataList;
        mContext = context;

    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_help_info, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {

        ViewHolder viewHolder = (ViewHolder) holder;
        IndexHelpInfoBean indexHelpInfoBean = mDataList.get(position);

        viewHolder.tvHelpInfoKindName.setText(indexHelpInfoBean.getHelpInfoName());

        Glide.with(mContext)
                .load(indexHelpInfoBean.getApplyPicResId())
                .into(viewHolder.ivHelpInfo);

        viewHolder.ivHelpInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (position==2) {
                    mContext.startActivity(new Intent(mContext, ActivityRecoverOrg.class));
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }


    private class ViewHolder extends RecyclerView.ViewHolder {


        private ImageView ivHelpInfo;
        private TextView tvHelpInfoKindName;

        public ViewHolder(View itemView) {
            super(itemView);

            ivHelpInfo = (ImageView) itemView.findViewById(R.id.iv_help_info);
            tvHelpInfoKindName = (TextView) itemView.findViewById(R.id.tv_help_info_kind_name);

        }
    }


}

